package com.yongbao.controller.admin;

import com.yongbao.common.PageInfo;
import com.yongbao.common.WebResponse;
import com.yongbao.common.annotation.WebAccess;
import com.yongbao.model.request.DishOrderRequest;
import com.yongbao.model.request.DishOrderSubStatisticsRequest;
import com.yongbao.model.vo.DishOrderVO;
import com.yongbao.model.vo.manual.DishOrderSubAreaStatisticsVO;
import com.yongbao.service.DishOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
 * @author zhanghong
 */
@RestController
@RequestMapping("/admin/dishOrder")
@Api(value = "【管理端】订单模块", tags = {"【管理端】订单模块"})
public class AdminDishOrderController {

    @Autowired
    private DishOrderService dishOrderService;

    @WebAccess(login = true)
    @ApiOperation(value = "根据主键查询", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/get/{id}")
    public WebResponse<DishOrderVO> getByKey(HttpServletRequest request, @PathVariable("id") long id) {
        return WebResponse.build(dishOrderService.getByKey(id));
    }

    @WebAccess(login = true)
    @ApiOperation("分页查询")
    @PostMapping("/pageQuery")
    public WebResponse<PageInfo<DishOrderVO>> pageQuery(@RequestBody DishOrderRequest request) {
        return WebResponse.build(dishOrderService.pageQuery(request));
    }

    @WebAccess(login = true)
    @ApiOperation("列表查询")
    @PostMapping("/listQuery")
    public WebResponse<List<DishOrderVO>> listQuery(@RequestBody DishOrderRequest request) {
        return WebResponse.build(dishOrderService.listQuery(request));
    }



    //@WebAccess(login = true)
    //@ApiOperation("新增")
    //@PostMapping("/add")
    //public WebResponse<Boolean> add(@Valid @RequestBody DishOrderRequest request) {
    //    return WebResponse.build(dishOrderService.add(request));
    //}
    //
    //@WebAccess(login = true)
    //@ApiOperation("修改")
    //@PostMapping("/update")
    //public WebResponse<Boolean> updateByKey(@Valid @RequestBody DishOrderRequest request) {
    //    return WebResponse.build(dishOrderService.updateByKey(request));
    //}

    @WebAccess(login = true)
    @ApiOperation("删除")
    @PostMapping("/delete")
    public WebResponse<Boolean> deleteByKey(@RequestParam String ids) {
        return WebResponse.build(dishOrderService.delByKey(ids));
    }

    @WebAccess(login = true)
    @ApiOperation("统计分页查询")
    @PostMapping("/statisticsPageQuery")
    public WebResponse<PageInfo<DishOrderVO>> statisticsPageQuery(@RequestBody DishOrderRequest request) {
        return WebResponse.build(dishOrderService.pageQuery(request));
    }

    @WebAccess(login = true)
    @ApiOperation("查询区域统计")
    @PostMapping("/areaStatistics")
    public WebResponse<List<DishOrderSubAreaStatisticsVO>> areaStatistics(@RequestBody DishOrderRequest request) {
        return WebResponse.build(dishOrderService.areaStatistics(request));
    }
}
